home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / Extras / ODE / ajf_mm < prev    next >
Encoding:
Text File  |  1991-12-03  |  1.1 KB  |  48 lines

  1. \ ------------------------------------------------------
  2. \
  3. \ Host specific code for AMIGA running JFORTH
  4. \ for support of HMSL
  5. \
  6. \ Author: Phil Burk
  7. \
  8. \ Copyright 1986 Phil Burk
  9. \
  10. \ Created 8/20/86
  11. \ MOD: PLB 10/20/86 Separated from AJF_RTC
  12. \ MOD: PLB 3/32/90 Added MM.ALLOC?
  13. \ 00001 PLB 11/20/91 Change ER.REPORT to ABORT"
  14. \ 00002 PLB 12/4/91 Fixed stack bug in MM.ZALLOC?
  15.  
  16. \ -------------------------------------------------------
  17.  
  18. ANEW TASK-AJF_MM
  19.  
  20. V: MM-TYPE  ( Only used on AMIGA, for specifying CHIP | PUBLIC, etc. )
  21. MEMF_PUBLIC mm-type !
  22.  
  23. : MM.ALLOC?  ( numbytes -- address | 0 , allocate bytes, 0 if can't )
  24.     mm-type @ swap allocblock
  25.     MEMF_PUBLIC mm-type !  ( set back to default )
  26. ;
  27.  
  28. : MM.ALLOC  ( numbytes -- address, allocate bytes, error if can't )
  29.     mm.alloc? dup 0=
  30.     abort" MM.ALLOC - Not enough memory!!!" \ 00001
  31. ;
  32.  
  33. : MM.ZALLOC ( numbytes -- address , allocate and zero out memory )
  34.     dup mm.alloc
  35.     dup rot 0 fill
  36. ;
  37.  
  38. : MM.ZALLOC? ( numbytes -- address | 0, allocate and zero out memory )
  39.     dup mm.alloc? dup \ 00002
  40.     IF dup rot 0 fill
  41.     ELSE nip
  42.     THEN
  43. ;
  44.  
  45. : MM.FREE ( address -- , free allocated memory )
  46.     freeblock
  47. ;
  48.